<?php 
	include('function/connection.php');
	include('function/function.php');
	if(isset($_GET['action']) && $_GET['action'] == "insert"){		
		$sql="INSERT INTO tbl_suppliers (sup_id,sup_name,sup_address,sup_contact1, sup_contact2)
		VALUES(
			'$_POST[txtCusID]',
			'$_POST[txtCusName]',
			'$_POST[txtCusAddress]',
			'$_POST[txtCusContact1]',
			'$_POST[txtCusContact2]')";
	
		mysql_query($sql);
		pageRedirect("index.php?page=supplier_list&action=supplier_list_addnew&","Added successful...!");
	}
	if(isset($_GET['action']) && $_GET['action'] == "update"){
		$sql= "UPDATE tbl_suppliers SET
				sup_id = '".$_POST['txtCusID']."',
				sup_name = '".$_POST['txtCusName']."',
				sup_address = '".$_POST['txtCusAddress']."',
				sup_contact1 = '".$_POST['txtCusContact1']."',
				sup_contact2 = '".$_POST['txtCusContact2']."'
			WHERE id = $_GET[id]";
			
		mysql_query($sql);
		pageRedirect("index.php?page=supplier_list&action=supplier_list&","Updated successful....!");
	}
	
	if(isset($_GET['action']) && $_GET['action'] == "delete"){
		$sql = "DELETE FROM tbl_suppliers
				WHERE id = $_GET[id]";
				
		mysql_query($sql);		
		pageRedirect("index.php?page=supplier_list&action=supplier_list&","Deleted successful....!");
	}
?>